layui.use(['layer','tree','jquery','form','element', 'laydate','laypage','util','laytpl'], function(){
	 var layer = layui.layer
	,tree = layui.tree
	,layedit = layui.layedit
	,form = layui.form()
	,element = layui.element()
	,laydate = layui.laydate
	,laypage=layui.laypage
	,laytpl = layui.laytpl
	,util = layui.util
	,$=layui.jquery;


	$(function(){

		$("#researchbox .togglebtn").hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		}).on("click",function(){
			var $wrapper=$("#researchbox .wrapper");
			var $this=$(this);
			if($wrapper.is(":hidden")){
				$wrapper.slideDown("normal");
			}else{
				$wrapper.slideUp("normal");
			}
		});


	
		$("#morere").on("click",function(){
			$(".morepanel").slideToggle();
			$(this).find("i").toggleClass("rotate-180");
		});	
		$("#classtree").on("click",".layui-icon",function(e){
			e.stopPropagation();
		});
		form.on('select(Field)', function(data){
		  //console.log(data.elem); //得到checkbox原始DOM对象
		  //console.log(data.value); //复选框value值，也可以通过data.elem.value得到
		  //$("input.checkchild").prop("checked",data.elem.checked);
		  var $keyword=$("input[name='keyword']");
		  var $datebybox=$("#datebybox");
		  if(data.value=="UpdateTime"){
			$keyword.attr({"lay-verify":"date","placeholder":"yyyy-m-d"}).val("")
				.on("click",function(){
					laydate({elem:this,max: laydate.now(),format: 'YYYY-MM-DD'});
					return false;
				});
			$datebybox.show();
		  }else if(data.value=="ID"){
			$keyword.attr({"lay-verify":"number","placeholder":"文章ID"}).val("")
				.off("click");	
			$datebybox.hide();	  	
		  }else{
			$keyword.attr({"lay-verify":"title","placeholder":"搜索词"}).val("")
				.off("click");
			$datebybox.hide();		  	
		  }
		});
			
		//GetArticleList1(initOptions,0);
		//fenye();
		$("#resetbtn").on("click",function(){
			$("form#researchform")[0].reset();
			$("#shuxingDown dd").removeClass("layui-this").find("i").remove();
			$("input[name=OnTop],input[name=IsElite],input[name=IsHot],input[name=IsDel]").val("False");
			form.render();
			requestOptions = $.extend(initOptions,{"MaxPerPage":$("select[name='perpage']").val()});
			GetArticleList(requestOptions,1);
		});	
	

		//下拉菜单
		$(".downpanel").on("click",".layui-select-title",function(e){
			$(".layui-form-select").not($(this).parents(".layui-form-select")).removeClass("layui-form-selected");
			$(this).parents(".layui-form-select").toggleClass("layui-form-selected");
			e.stopPropagation();
		}).on("click",".layui-form-checkbox",function(e){
			e.stopPropagation();
		});



	});


});
